<?
define('MYEMAIL','enquiry@yellowpages.vn');//enquiry@yellowpages.com.vn
class sendEmail{
 var $subject;
 var $from;
 var $email;
 var $body;
 var $head;
 var $lang;
 var $nm;
 var $mails; 
 
 function sendEmail($p, $k, $lang){// print_r($p);
  $this->subject	= $_REQUEST['txtSubject'];
  $this->from		= $p[$k[3]];
  $this->email 		= 'enquiry@yellowpages.vn';//'quochuypro@gmail.com';
  $this->lang		= $lang;
 } 
 function getBody(){  return $this->body; }
 function setBody(){//istype, $_POST, k
  $a = func_get_args(); print_r($a);
  if($_REQUEST['flagit'] =='sa'){
   switch($this->lang){
    case 'vn':
	 $t="<font style=font-family:arial;font-size:12px><b>Đến Công Ty:</b> ".$_REQUEST['kw']."<br><b>Tên:</b> ".
   	   $_REQUEST['txtName']."<BR><b>Công Ty:</b> ".$_REQUEST['txtCompany']."<BR><b>Địa chỉ:</b> ".$_REQUEST['txtAddress'].
	   "<BR><b>Email:</b> ".$_REQUEST['txtEmail']."<BR><b>Điện thoại:</b> ".$_REQUEST['txtPhone']."<BR><br><font style=color:black>Cung cấp bởi: YellowPages.vn-Niên giám trang vàng chính thức tại Việt Nam<BR>
	   <b>Hồ Chí Minh:</b> (08) 4043838 &nbsp;&nbsp; <b>Hà Nội:</b> (04) 7192302 &nbsp;&nbsp; <b>Bình Dương:</b> (0650) 759439<br>
		<b>Email:</b> enquiry@yellowpages.vn<BR><br><b>Enquiry:</b> <PRE>".$_REQUEST['areaEnquiry']."<PRE></font>";
	 break;
	case 'us':
     $t="<font style=font-family:arial;font-size:12px><b>To Company:</b> ".$_REQUEST['kw']."<br><b>User name:</b> ".
   	   $_REQUEST['txtName']."<BR><b>Company:</b> ".$_REQUEST['txtCompany']."<BR><b>Address:</b> ".$_REQUEST['txtAddress'].
	   "<BR><b>Email:</b> ".$_REQUEST['txtEmail']."<BR><b>Phone Number:</b> ".$_REQUEST['txtPhone']."<BR><br><font style=color:black>Provided by: YellowPages.vn - Vietnam's Official Yellow Pages<BR>
	   <b>HCMC:</b> (08) 4043838 &nbsp;&nbsp; <b>Hanoi:</b> (04) 7192302 &nbsp;&nbsp; <b>Binh Duong:</b> (0650) 759439<br><b>Email:</b> enquiry@yellowpages.vn<BR><br><b>Enquiry:</b> <PRE>".$_REQUEST['areaEnquiry']."<PRE></font>";
    break;
	default:
   $t="<font style=font-family:arial;font-size:12px><b>你的名字:</b> ".$_REQUEST['kw']."<br><BR><b>你的名字:</b> ".
   	   $_REQUEST['txtName']."<BR><b>公司名称:</b> ".$_REQUEST['txtCompany']."<BR><b>地址:</b> ".$_REQUEST['txtAddress'].
	   "<BR><b>电子邮件地址:</b> ".$_REQUEST['txtEmail']."<BR><b>电话号码:</b> ".$_REQUEST['txtPhone']."<BR><br><font style=color:black>越南黄页 - YellowPages.vn<BR>
	   <b>胡志明市:</b> (08) 4043838 &nbsp;&nbsp; <b>河内:</b> (04) 7192302 &nbsp;&nbsp; <b>平阳省:</b> (0650) 759439 &nbsp;&nbsp;<br>
		<b>Email:</b> enquiry@yellowpages.vn<BR><br><b>Enquiry:</b> <PRE>".$_REQUEST['areaEnquiry']."<PRE></font>";
   }
  }else 
  {
   $pro = $this->getClassBrand('txtpro'); $brd = $this->getClassBrand('txtbrd');
   switch($this->lang){
    case 'vn':
	 $t = "<b>CẬP NHẬT THÔNG TIN</b><br><br><b>Tên Công ty tiếng anh:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtCompany'].
   		"<br><b>Tên công ty tiếng việt:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtName']."<br><b>Tên Công ty tiếng hoa:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtCompanyhoa']."<br><b>Địa chỉ:</b>&nbsp;&nbsp;
		&nbsp; ".$_REQUEST['txtAddress']."<br><b>Tỉnh/TP:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtcity']."<br><b>Số điện thoại:</b>&nbsp;&nbsp;
		&nbsp; ".$_REQUEST['txtPhone']."<br><b>Số fax:</b>&nbsp;&nbsp;&nbsp; ".$_REQUEST['txtFax']."<br><b>Email: </b>&nbsp;
		&nbsp;&nbsp;".$_REQUEST['txtEmail']."<br><b>Website:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtwebsite']."<br><b>Giám đốc/Quản lý:</b>
		&nbsp;&nbsp;&nbsp; ".$_REQUEST['txtpostal']."<br><b>Chức danh:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtdesi']."<br><b>Ngành nghề:</b>
		&nbsp;&nbsp;&nbsp;".$pro."<br><b>Thương hiệu:</b>&nbsp;&nbsp;&nbsp; ".$brd."<br><b>Người liên hệ:</b> &nbsp;&nbsp;
		&nbsp;".$_REQUEST['txtcontact']."<br><b>Chức vụ:</b>&nbsp;&nbsp;&nbsp; ".$_REQUEST['txtpos']."<br><b>Điện thoại liên hệ:</b>
		&nbsp;&nbsp;&nbsp; ".$_REQUEST['txtConNum']."<br><br><b>Chú thích:</b> &nbsp;&nbsp;&nbsp;
		<PRE style=font-family:arial>".$_REQUEST['areaEnquiry']."<PRE>";
	 break;
	case 'us':
	 $t = "<b>UPDATE INFORMATION</b><br><br><b>English Company:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtCompany'].
   		"<br><b>Vietnamese name:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtName']."<br><b>Chinese name:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtCompanyhoa']."<br><b>Address:</b>&nbsp;&nbsp;&nbsp; ".
		$_REQUEST['txtAddress']."<br><b>City:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtcity']."<br><b>Phone Number:</b>&nbsp;&nbsp;
		&nbsp; ".$_REQUEST['txtPhone']."<br><b>Fax Number:</b>&nbsp;&nbsp;&nbsp; ".$_REQUEST['txtFax']."<br><b>Email: </b>&nbsp;
		&nbsp;&nbsp;".$_REQUEST['txtEmail']."<br><b>Website:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtwebsite']."<br><b>Director:</b>
		&nbsp;&nbsp;&nbsp; ".$_REQUEST['txtpostal']."<br><b>Designation:</b> &nbsp;&nbsp;&nbsp;".$_REQUEST['txtdesi']."<br><b>Classes:</b>
		&nbsp;&nbsp;&nbsp;".$pro."<br><b>brands:</b>&nbsp;&nbsp;&nbsp; ".$brd."<br><b>Contact Person:</b> &nbsp;&nbsp;
		&nbsp;".$_REQUEST['txtcontact']."<br><b>Position:</b>&nbsp;&nbsp;&nbsp; ".$_REQUEST['txtpos']."<br><b>Contact Number:</b>
		&nbsp;&nbsp;&nbsp; ".$_REQUEST['txtConNum']."<br><br><b>Comments/Feedback:</b> &nbsp;&nbsp;&nbsp;
		<PRE style=font-family:arial>".$_REQUEST['areaEnquiry']."<PRE>";
	 break;
	default:
		$t="<font style=font-family:arial;font-size:12px><b>你的名字:</b> ".$_REQUEST['kw']."<br><BR><b>你的名字:</b> ".
   	   $_REQUEST['txtName']."<BR><b>公司名称:</b> ".$_REQUEST['txtCompany']."<BR><b>地址:</b> ".$_REQUEST['txtAddress'].
	   "<BR><b>电子邮件地址:</b> ".$_REQUEST['txtEmail']."<BR><b>电话号码:</b> ".$_REQUEST['txtPhone']."<BR><br><font style=color:black>越南黄页 - YellowPages.vn<BR>
	   <b>胡志明市:</b> (08) 4043838 &nbsp;&nbsp; <b>河内:</b> (04) 7192302 &nbsp;&nbsp; <b>平阳省:</b> (0650) 759439 &nbsp;&nbsp;<br>
		<b>Email:</b> enquiry@yellowpages.vn<BR><br><b>Enquiry:</b> <PRE>".$_REQUEST['areaEnquiry']."<PRE></font>";
	   }
  }
  $this->body = $t; //echo($t);
 }
 function getHeader(){ return $this->head;}
 function setHeader($p, $k){// print_r($p);
  if($p[$k[7]]) 
   $emails = $p[$k[7]];
  else
   $emails = 'enquiry@yellowpages.vn';//quochuypro@gmail.com*
   
  $headers  = "MIME-Version: 1.0 \r\n";
  $headers .= "Content-type: text/html; charset=utf-8 \r\n";
   if($p['flagit']='sa'){
   	switch($this->lang){
    case 'cn':
	$headers .= 'To: <'.$p['url']."> \r\n";
	 $headers .= 'From: "'.$p[$k[1]].'"<'.$this->from."> \r\n";
  	 $headers .= "Bcc: huong@yellowpages.vn \r\n";
	 break;
	 case 'us':   		
	 $headers .= 'To: "'.$p['kw'].'"<'.$p['url']."> \r\n";
	 $headers .= 'From: "'.$p[$k[1]].'"<'.$this->from."> \r\n";
  	 $headers .= "Bcc: huong@yellowpages.vn \r\n";
	 break;
	  case 'vn':   		
	 $headers .= 'To: "'.$p['kw'].'"<'.$p['url']."> \r\n";
	 $headers .= 'From: "'.$p[$k[1]].'"<'.$this->from."> \r\n";
  	 $headers .= "Bcc: huong@yellowpages.vn \r\n";
	 break;
	 }
  }else{
   $headers .= 'To: "Chinh" <db@yellowpages.vn> '." \r\n";
   $headers .= "From: ".$p['txtEmail']." \r\n";
   
  }
  $this->head = $headers;
 }
 
 function sendit(){// $_POST, $k,$lang
  $a = func_get_args(); //print_r($a);
  $this->nm = $a[0]['kw'];
  $this->mails = $_REQUEST['url']; //echo($a[0][$a[1][7]]."fgd");
  
  $str = $this->changeLang($this->lang);
  if($this->mails===''){
   $this->email = "enquiry@yellowpages.vn";//'huong@yellowpages.com.vn'; 
   $t = $str[0];
  }else{
  $this->email = $this->mails;
   if($a[2]!=''){
    $t = $str[1];
   }else{
    $t = $str[2];
   }
  }
  if($_REQUEST['flagit']=='') $this->email='';
  mail($this->email,$this->subject,$this->body,$this->head);
//  mail("vanyen12@gmail.com",$this->subject,$this->body, $headers);
  //echo($this->email."<br>".$this->subject."<br>".$this->body."<br>".$this->head."<br>");
  echo($t);
 }
 
 function getClassBrand($nm){
  $t='';
  for($i=0;$i<count($_REQUEST[$nm]);$i++){
   if($_REQUEST[$nm][$i]!='') $t .=$_REQUEST[$nm][$i]."; ";
  }
  return substr($t,0,strlen($t)-2);
 }
 function changeLang($lang){
  $a = array();
  switch($lang){
   case 'us':
    $a[]="<table class='formborderstyle sz12' cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0>
	<tr><td height=20 colspan=2></td></tr>
	<tr><td height=10 colspan=2 align=center class=sz12><b>Your enquiry has sent sucessfully</b></td></tr>
	<tr><td height=7 colspan=2></td></tr>
		<tr><td vAlign=top align=middle class='sz12 pdlr20'>Thank you for writing us. Because of your company you enquiried doesn't have 
		email address, we will contact the company and reply as soon as possible. <p></td></tr><tr><td height=20 colspan=2></td></tr>";
	$a[]="<table class='formborderstyle sz12' cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0>
	<tr><td height=20 colspan=2></td></tr>
	<tr><td height=10 colspan=2 align=center class=sz12><b>Your enquiry has sent sucessfully</b></td></tr>
	<tr><td height=7 colspan=2></td></tr>
	<tr><td colspan=2 align=center><b>To Company Name:</b>&nbsp;&nbsp;".$this->nm."</td></tr>
	  <tr><td class=sz12 colspan=2 align=center><b>Email:</b>&nbsp;&nbsp;".$this->mails."</td></tr>
	  <tr><td align=center nowrap colspan=2>Thank you for writing us. We will reply your enquiry as soon as possible.</td>
	  </tr><tr><td height=20 colspan=2></td></tr></table>";
	$a[]="<table class='formborderstyle sz12 pdlr20' cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0><tr><td height=20 colspan=2></td></tr><tr><td align=center class='sz12 pdlr20'><b>Your update has sent successfully.</b><br><br><b>To Company Name:</b> 
	  &nbsp;&nbsp;Yellow Pages JSC<br><b>Email:</b>&nbsp;&nbsp;db@yellowpages.vn <br><br>Thank you for writing us. We will update your
	  information as soon as possible. </td></tr><tr><td height=20 colspan=2></td></tr></table>";
	break;
   case 'vn':
   $a[]="<table class='formborderstyle sz12' cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0>
		<tr><td height=20 colspan=2></td></tr>
	<tr><td height=10 colspan=2 align=center class=sz12><b>Yêu cầu của bạn đã gửi thành công</b></td></tr>
	<tr><td height=7 colspan=2></td></tr>		
		<tr><td vAlign=top align=middle 'sz12 pdlr20'>Cám ơn bạn đã gửi yêu cầu đến chúng tôi. Công ty bạn liên hệ hiện chưa có địa chỉ email,<br>chúng tôi sẽ liên hệ giúp bạn trong thời gian sớm nhất.</td></tr><tr><td height=20 colspan=2></td></tr></table>";
	$a[]="<table class=formborderstyle cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0><tr><td height=20 colspan=2></td></tr><tr><td height=10 colspan=2 align=center class=sz12><b>Yêu cầu của bạn đã gửi thành công</b></td></tr><tr><td height=7 colspan=2></td></tr><tr><td colspan=2 align=center class=sz12><b>Đến Công Ty:<b>&nbsp;&nbsp;".$this->nm."</td></tr>
	  <tr><td colspan=2 align=center class=sz12><b>Email:</b>&nbsp;&nbsp;".$this->mails."</td></tr>
	  <tr><td align=center nowrap colspan=2 class=sz12>Cám ơn bạn đã gửi yêu cầu đến chúng tôi. Chúng tôi sẽ trả lời bạn trong thời gian sớm nhất.</td>
	  </tr><tr><td height=20 colspan=2></td></tr></table>";
	$a[]="<table class=formborderstyle cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0><tr><td height=20 colspan=2></td></tr><tr><td align=center class='sz12 pdlr20'><b>Thông tin cập nhật của bạn đã gửi thành công.</b> <br><br><b>Đến Công Ty:</b> 
	  &nbsp;&nbsp;Yellow Pages JSC <br><b>Email:</b>&nbsp;&nbsp;db@yellowpages.vn <br><br>Cám ơn bạn đã gửi yêu cầu đến chúng tôi. Thông tin của bạn sẽ được cập nhật <br>trong thời gian sớm nhất.
	</td></tr><tr><td height=20 colspan=2></td></tr></table>";
    break;
   case 'cn':
   $a[]="<table class=formborderstyle cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0><tr><td height=20 colspan=2></td></tr><tr><td align=center class=sz12>你的建议提交成功，我们会24小时内给您回复！</td></tr>
		<tr><td vAlign=top align=middle class=sz12>请关闭窗口</td></tr><tr><td height=20 colspan=2></td></tr>";
   $a[]="<table class=formborderstyle cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0>
	<tr><td height=20 colspan=2></td></tr>
	<tr><td height=10 colspan=2 align=center class=sz12>你的建议提交成功，我们会24小时内给您回复！</td></tr>
	<tr><td height=7 colspan=2></td></tr>
	<tr><td colspan=2 align=center class=colCom>公司名称:&nbsp;&nbsp;".$this->nm."
	  <br><br>邮件:&nbsp;&nbsp;".$this->mails."</td></tr>
	  <tr><td class=sz12 align=center nowrap colspan=2>请关闭窗口</td>
	  <tr><td height=20 colspan=2></td></tr>
	  </tr></table>";
	$a[]="<table class=formborderstyle cellSpacing=1 cellPadding=5 width=547 bgColor=#ffffb3 border=0><tr><td height=20 colspan=2></td></tr><tr><td align=center class=sz12>你的修改公司信息提交成功，我们会24小时内给您回复！
    <br>请关闭窗口</td></tr><tr><td height=20 colspan=2></td></tr></table>";
    break;
  }
  return $a; 
 }
}
?>